package cn.yangliu.nacos.comm.enums;

import cn.yangliu.nacos.comm.ex.ResultCode;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2019 -12-30
 */
public enum GlobalResultCode implements ResultCode {
    /**
     * Success global result code.
     */
    SUCCESS(200, "success"),
    /**
     * Faild global result code.
     */
    FAILD(500, "faild"),
    /**
     * current class instance's member.
     * The Data not exist.
     */
    DATA_NOT_EXIST(404, "data not exist"),

    /**
     * current class instance's member.
     * The Username already exist.
     */
    USERNAME_ALREADY_EXIST(400, "username already exist"),

    /**
     * current class instance's member.
     * The Email already exist.
     */
    EMAIL_ALREADY_EXIST(400, "email already exist"),

    /**
     * current class instance's member.
     * The Mobile already exist.
     */
    MOBILE_ALREADY_EXIST(400, "mobile already exist"),

    /**
     * current class instance's member.
     * The Interface address not found.
     */
    INTERFACE_ADDRESS_NOT_FOUND(404, "interface address not found"),

    /**
     * current class instance's member.
     * The Unsupported response type.
     */
    UNSUPPORTED_RESPONSE_TYPE(400, "unsupported response type"),

    /**
     * current class instance's member.
     * The Param is blank.
     */
    PARAM_IS_BLANK(400, "param is blank"),

    REVOKE_TOKEN_FAILED(500, "revoke token failed"),
    /**
     * current class instance's member.
     * The Access token no authority.
     */
    ACCESS_TOKEN_NO_AUTHORITY(401, "access token no authority"),
    /**
     * current class instance's member.
     * The User is not login.
     */
    USER_IS_NOT_LOGIN(403, "user is not login"),
    /**
     * current class instance's member.
     * The Miss token.
     */
    MISS_TOKEN(403, "miss token in header"),
    /**
     * current class instance's member.
     * The Token illegal.
     */
    TOKEN_ILLEGAL(403, "token is illegal"),
    /**
     * current class instance's member.
     * The Operate self forbidden.
     */
    OPERATE_SELF_FORBIDEN(400, "operate self forbiden"),
    /**
     * current class instance's member.
     * The Username or password error.
     */
    USERNAME_OR_PASSWORD_ERROR(403, "username or password error"),
    /**
     * current class instance's member.
     * The Access define.
     */
    ACCESS_DEFINE(401, "access define"),
    /**
     * current class instance's member.
     * The Invalid client.
     */
    INVALID_CLIENT(401, "invalid client"),
    /**
     * current class instance's member.
     * The Invalid grant.
     */
    INVALID_GRANT(401, "invalid grant"),
    /**
     * current class instance's member.
     * The Bad request.
     */
    BAD_REQUEST(400, "bad request"),
    /**
     * current class instance's member.
     * The Access token invalid.
     */
    ACCESS_TOKEN_INVALID(401, "access token invalid"),
    /**
     * current class instance's member.
     * The Unauthorized client.
     */
    UNAUTHORIZED_CLIENT(401, "unauthorized client"),
    /**
     * current class instance's member.
     * The Insufficient scope.
     */
    INSUFFICIENT_SCOPE(403, "insufficient scope"),
    /**
     * current class instance's member.
     * The Access denied.
     */
    ACCESS_DENIED(403, "access denied"),
    /**
     * current class instance's member.
     * The Unauthorized user.
     */
    UNAUTHORIZED_USER(401, "unauthorized user"),
    /**
     * current class instance's member.
     * The Unsupported grant type.
     */
    UNSUPPORTED_GRANT_TYPE(400, "unsupported grant type"),
    /**
     * current class instance's member.
     * The Insufficient authentication.
     */
    INSUFFICIENT_AUTHENTICATION(403, "insufficient authentication"),
    /**
     * current class instance's member.
     * The Method not allowed.
     */
    METHOD_NOT_ALLOWED(405, "method not allowed"),
    /**
     * Unauthorized global result code.
     */
    UNAUTHORIZED(401, "unauthorized"),
    /**
     * current class instance's member.
     * The System inner error.
     */
    SYSTEM_INNER_ERROR(500, "system inner error"),

    /**
     * current class instance's member.
     * The Interface request timeout.
     */
    INTERFACE_REQUEST_TIMEOUT(404, "interface request timeout"),
    /**
     * 415
     */
    UNSUPPORTED_MEDIA_TYPE(415, "unsupported media type"),
    /**
     * current class instance's member.
     * The Param is invalid.
     */
    PARAM_IS_INVALID(400, "param is invalid"),
    /**
     * current class instance's member.
     * The Param type bind error.
     */
    PARAM_TYPE_BIND_ERROR(400, "param type bind error"),
    ;
    /**
     * current class instance's member.
     * The Code.
     */
    private int code;

    /**
     * current class instance's member.
     * The Msg.
     */
    private String msg;

    /**
     * Instantiates a new Global result code.
     *
     * @param code the code
     * @param msg  the msg
     */
    GlobalResultCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * current class method for getter.
     * Gets code.
     *
     * @return the code
     */
    @Override
    public int getCode() {
        return code;
    }

    /**
     * current class method for getter.
     * Gets msg.
     *
     * @return the msg
     */
    @Override
    public String getMsg() {
        return msg;
    }
}
